﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class TaoBaoApi_TB_Shipping : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            new TBCommon().BindTBShop(ddlShop);
    }
    protected void btnDown_Click(object sender, EventArgs e)
    {
        string name = ddlShop.SelectedItem.Text;
        if (name.Length == 0)
        {
            ShowMessage("请选择淘宝店铺。");
            return;
        }
        string password = ddlShop.SelectedValue;

        string errMsg = null;
        string sessionId = null;
        int ret = 0;   
        ret = new TaoBaoAPI().GetTBSessionId(Page,name, password, new TaoBaoAPI().GetAppKey(), ref errMsg, ref sessionId);
        if (ret != 0)
        {
            ShowMessage(errMsg);
            return;
        }         
        new TB_Shipping().DownTBShipping(name, password, new TaoBaoAPI().GetAppKey(), new TaoBaoAPI().GetCertCode(), sessionId);
        ShowMessage("下载淘宝物流数据全部完成。");
    }    
    void ShowMessage(string msg)
    {
        new TBCommon().ShowMessage(Page, msg);
    }
}
